import axios from "axios"

export const request = axios.create({
  baseURL: import.meta.env.VITE_APP_BASE_URL,
  timeout: 5000,
})

// 响应拦截器
request.interceptors.response.use((config) => {
  return config.data
})

// 请求拦截器
request.interceptors.request.use((config) => {
  const token = localStorage.getItem("token")
  if (token) {
    config.headers.Authorization = "Beaer " + token
  }
  return config
})
